package com.nacos.example.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

/**
 * @author wy
 * @date 2022/04/24
 * @description  使用@Value获取项目指定配置文件中的值，使用@PropertySource指定要读取的配置文件路径
 **/
@Component
@PropertySource(value = "classpath:config.properties", encoding = "utf-8")
public class TestValue2 {

    @Value("${teacher.name}")
    private String name;

    @Value("${teacher.age}")
    private Integer age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }
}
